$def with (page)
$ is_privileged_user = ctx.user and (ctx.user.is_admin() or ctx.user.is_super_librarian())

<header id="header-bar" class="header-bar">


  $if ctx.user:
    $ loginLinks = [
    $     { "href": "/account/books", "text": _("My Books"), "track": "MyBooks", "subheading": _("Loans, Reading Log, Lists, Stats") },
    $     { "href": ctx.user.key, "text": _("My Profile"), "track": "MyProfile" },
    $     { "href": homepath() + "/account", "text": _("Settings"), "track": "MySettings" },
    $     { "post": "/account/logout", "text": _("Log out"), "track": "Logout", "name":"hamburger-logout" },
    $ ]
      $if is_privileged_user:
        $ loginLinks.insert(2, { "href": homepath() + "/merges", "text": _("Pending Merge Requests"),"track": "MyRequests", "badge": True })
  $else:
    $ loginLinks = [
    $     { "loginClass": "login-links" }
    $ ]
  $ myBooksLinks = [
  $     { "href": homepath() + "/account/books", "text": _("My Books"), "track": "MyBooks" },
  $ ]
  $ browseLinks = [
  $     { "href": "/subjects", "text": _("Subjects"), "track": "Subjects" },
  $     { "href": "/trending", "text": _("Trending"), "track": "Trending" },
  $     { "href": "/explore", "text": _("Library Explorer"), "track": "Explore" },
  $     { "href": "/lists", "text": _("Lists"), "track": "Lists" },
  $     { "href": "/collections", "text": _("Collections"), "track": "Collections" },
  $     { "href": "/k-12", "text": _("K-12 Student Library"), "track": "K12Library" },
  $     { "href": "/booktalks", "text": _("Book Talks"), "track": "BookTalks" },
  $     { "href": "/random", "text": _("Random Book"), "track": "RandomBook" },
  $     { "href": "/advancedsearch", "text": _("Advanced Search"), "track": "AdvancedSearch" }
  $ ]
  $ contributeLinks = [
  $     { "href": "/books/add", "text": _("Add a Book"), "track": "AddBook" },
  $     { "href": "/recentchanges", "text": _("Recent Community Edits"), "track": "RecentEdits" }
  $ ]
  $ resourceLinks = [
  $     { "href": "/help", "text": _("Help & Support"), "track": "Help" },
  $     { "href": "/developers", "text": _("Developer Center"), "track": "DevelopersHelp" },
  $     { "href": "/librarians", "text": _("Librarians Portal"), "track": "LibrariansHelp" }
  $ ]
  $ hamburgerProps = {
  $  'name': 'hamburger',
  $  'links': [ { "subsection": _("My Open Library") } ] + loginLinks +
  $     [ { "subsection": _("Browse") } ] + browseLinks +
  $     [ { "subsection": _("Contribute") } ] + contributeLinks +
  $     [ { "subsection": _("Resources") } ] + resourceLinks,
  $  'image': '/static/images/hamburger-icon.svg',
  $  'image-class': 'hamburger__icon',
  $  'label': 'additional options menu',
  $  'show_mask': True
  $ }

  <div class="logo-component">
    <a href="/" title="$_('The Internet Archive\'s Open Library: One page for every book')">
      <div class="logo-txt">
        <img class="logo-icon" src="/static/images/openlibrary-logo-tighter.svg"
          width="189" height="47"
          alt="$_('Open Library logo')"/>
      </div>
    </a>
  </div>

  $ browseProps = {
  $   'name': 'browse',
  $   'label': _('Browse'),
  $   'links': browseLinks
  $ }

  $ myBooksProps = {
  $   'name': 'mybooks',
  $   'label': _('My Books'),
  $   'links': myBooksLinks
  $ }
  <ul class="navigation-component">
    <li>$:render_template("lib/header_dropdown", myBooksProps, track_prefix="MainNav")</li>
    <li>$:render_template("lib/header_dropdown", browseProps, track_prefix="MainNav")</li>
  </ul>

  <div class="search-component">
    <div class="search-bar-component">
      <div class="search-bar">
        <div class="search-facet">
          <label class="search-facet-selector">
            <span aria-hidden="true" class="search-facet-value">$_("All")</span>
            <select aria-label="Search by">
              <option value="all">$_("All")</option>
              <option value="title">$_("Title")</option>
              <option value="author">$_("Author")</option>
              <option value="text">$_("Text")</option>
              <option value="subject">$_("Subject")</option>
              <option value="lists">$_("Lists")</option>
              <option value="advanced">$_("Advanced")</option>
            </select>
          </label>
        </div>
        <form class="search-bar-input" action="/search" method="get">
          <input type="text" name="q" placeholder="$_('Search')" aria-label="Search" autocomplete="off">
          <input name="mode" type="checkbox" aria-hidden="true" aria-label="Search checkbox" checked="checked" value="" id="ftokenstop" class="hidden instantsearch-mode">
          <input type="submit" value="" class="search-bar-submit" aria-label="Search submit">
          <div class="vertical-separator"></div>
          <a
            id="barcode_scanner_link"
            class="search-by-barcode-submit"
            aria-label="$_('Search by barcode')"
            title="$_('Search by barcode')"
            href="/barcodescanner?returnTo=/isbn/$$$$$$"
          >
          </a>
        </form>
      </div>
      <div class="search-dropdown">
        <ul class="search-results">
        </ul>
      </div>
    </div>
  </div>

  $if not ctx.user:
    <ul class="auth-component">
      <li class="hide-me">
        <a class="btn"
           href="/account/login">$_("Log In")</a></li>
      <li><a class="btn primary" href="/account/create">$_("Sign Up")</a></li>
    </ul>

  $:render_template("lib/header_dropdown", hamburgerProps, track_prefix="Hamburger")

</header>
<header class="header-bar mobile">
  <ul class="navigation-component mobile">
    <li>$:render_template("lib/header_dropdown", myBooksProps, track_prefix="MainNav")</li>
    <li>$:render_template("lib/header_dropdown", browseProps, track_prefix="MainNav")</li>
  </ul>
</header>
